﻿/*
 * 文件名称：
 * 程序员：wangyun
 * 创建时间：2008/05/27
 * 
 * 功能说明：功能模块的字段类型控件，文本编辑器控件
 * 
 * 修改人员：yylu
 * 
 * 修改日期：2009/08/20
 * 
 * 修改记录：1)增加控件手写单独使用的代码
 */

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Whir.Common.WebHelper;

public partial class UserControls_FieldControl_MultipleHtmlTextType : Whir.Controls.ModelField.BaseFieldControl
{
    protected void Page_Load(object sender, EventArgs e)
    {            
        //设置编辑器的显示
        //string xmlPath = Server.MapPath(Whir.Common.Settings.GetString("XmlPath") + "SiteConfig.xml");
        string xmlPath = Server.MapPath("~"+Whir.Common.Settings.GetString("XmlPath") + "SiteConfig.xml");



        Type type = typeof(Whir.Config.Model.SiteConfig);
        Whir.Config.Model.SiteConfig siteModel = (Whir.Config.Model.SiteConfig)Whir.Common.XmlHelper.DeserializeObject(xmlPath, type);

        if (!IsPostBack)
        {

            Whir.BLL.Whir_FieldEditor bll = new Whir.BLL.Whir_FieldEditor();
            int fieldTextId = int.Parse(bll.GetList(" FieldID = " + this.FieldID).Tables[0].Rows[0][0].ToString());
            Whir.Model.Whir_FieldEditor model = bll.GetModel(fieldTextId);

            if (this.isSingleUse)
            {
                this.InitFieldControl(this.FieldID);
            }

            if (siteModel.Editor == "FckEditor")
            {
                Panel1.Visible = true;
                if (!string.IsNullOrEmpty(model.textWidth))
                    this.fckMultipleHtmlTextType.Width = int.Parse(model.textWidth);    //设置控件的宽度

                if (!string.IsNullOrEmpty(model.textHeight))
                    this.fckMultipleHtmlTextType.Height = int.Parse(model.textHeight);  //设置控件的长度

                this.fckMultipleHtmlTextType.ToolbarSet = "Default";
            }
            else
            {
                Panel2.Visible = true;
            }

            int ItemID = NetRequest.GetQueryInt("ItemID");
            if (ItemID == 0)
            {
                //添加操作，绑定默认值
                if (siteModel.Editor == "FckEditor")
                    this.fckMultipleHtmlTextType.Value = model.defaultValue;
                else
                    this.txtInfo_Content.Value = model.defaultValue;
            }
            else
            {
                if (siteModel.Editor == "FckEditor")
                    this.fckMultipleHtmlTextType.Value = FieldCommon.GetBindValue(this.FieldID, ItemID);
                else
                    //更新操作，绑定值
                    this.txtInfo_Content.Value = FieldCommon.GetBindValue(this.FieldID, ItemID);
            }
        }
        else
        {
            if (siteModel.Editor == "FckEditor")
                this.FieldValue = this.fckMultipleHtmlTextType.Value;
            else
                this.FieldValue = this.txtInfo_Content.Value;
        }
    }
}
